<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>MainViewBase.as</title>
<link rel="stylesheet" type="text/css" href="../../../../../SourceStyles.css"/>
</head>

<body><pre><span class="ActionScriptpackage">package</span> <span class="ActionScriptDefault_Text">com</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">flowersinc</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">shop</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">views</span>
<span class="ActionScriptBracket/Brace">{</span>
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">com</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">flowersinc</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">shop</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">events</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">HomeViewEvent</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">com</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">flowersinc</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">shop</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">model</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">Flower</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">net</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">URLLoader</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">flash</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">net</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">URLRequest</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">collections</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">ArrayCollection</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">containers</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">VBox</span>;
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">containers</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">ViewStack</span>;
    
    <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">org</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">goverla</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">managers</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">ApplicationManager</span>;

    <span class="ActionScriptReserved">public</span> <span class="ActionScriptclass">class</span> <span class="ActionScriptDefault_Text">MainViewBase</span> <span class="ActionScriptReserved">extends</span> <span class="ActionScriptDefault_Text">VBox</span>
    <span class="ActionScriptBracket/Brace">{</span>
        <span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">homeView</span> : <span class="ActionScriptDefault_Text">HomeView</span>;

        <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span><span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">viewStack</span> : <span class="ActionScriptDefault_Text">ViewStack</span>;
        
        <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span><span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">selectedFlower</span> : <span class="ActionScriptDefault_Text">Flower</span>;
        
        <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span><span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">flowers</span> : <span class="ActionScriptDefault_Text">ArrayCollection</span>;
        
            
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">onInitialize</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">_urlLoader</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">addEventListener</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">COMPLETE</span><span class="ActionScriptOperator">,</span> <span class="ActionScriptDefault_Text">onLoadComplete</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptDefault_Text">_urlLoader</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">load</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_urlRequest</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">onChangeViewStack</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">event</span> : <span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">viewStack</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">selectedIndex</span> <span class="ActionScriptOperator">==</span> 0<span class="ActionScriptBracket/Brace">)</span> <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptDefault_Text">homeView</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">startShuffle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;                
            <span class="ActionScriptBracket/Brace">}</span>

            <span class="ActionScriptReserved">if</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">viewStack</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">selectedIndex</span> <span class="ActionScriptOperator">==</span> 1<span class="ActionScriptBracket/Brace">)</span> <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptDefault_Text">homeView</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">stopShuffle</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptBracket/Brace">}</span> 
            
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">onImageSelected</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">event</span> : <span class="ActionScriptDefault_Text">HomeViewEvent</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">viewStack</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">selectedIndex</span> <span class="ActionScriptOperator">=</span> 1;    
            <span class="ActionScriptDefault_Text">selectedFlower</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">event</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">selectedFlower</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">onHomeImageClick</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">viewStack</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">selectedIndex</span> <span class="ActionScriptOperator">=</span> 0;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">onFlowerImageClick</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">viewStack</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">selectedIndex</span> <span class="ActionScriptOperator">=</span> 1;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">protected</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">onHelpImageClick</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">viewStack</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">selectedIndex</span> <span class="ActionScriptOperator">=</span> 2;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">onLoadComplete</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">evtObj</span>:<span class="ActionScriptDefault_Text">Event</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span> 
            <span class="ActionScriptDefault_Text">_flowersXML</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">XML</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">_urlLoader</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">data</span><span class="ActionScriptBracket/Brace">)</span>; 
            <span class="ActionScriptDefault_Text">addFlowers</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">addFlowers</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span> : <span class="ActionScriptReserved">void</span> 
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">result</span> : <span class="ActionScriptDefault_Text">ArrayCollection</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">ArrayCollection</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
            
            <span class="ActionScriptReserved">for each</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">flower</span> : <span class="ActionScriptDefault_Text">XML</span> <span class="ActionScriptReserved">in</span> <span class="ActionScriptDefault_Text">_flowersXML</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptBracket/Brace">)</span> 
            <span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">flowerInstance</span> : <span class="ActionScriptDefault_Text">Flower</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Flower</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
                
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">color</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptOperator">@</span><span class="ActionScriptDefault_Text">color</span>;
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">name</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptOperator">@</span><span class="ActionScriptDefault_Text">type</span>;
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">price</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptOperator">@</span><span class="ActionScriptDefault_Text">price</span>;
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">amount</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptOperator">@</span><span class="ActionScriptDefault_Text">amount</span>;
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">image</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptOperator">@</span><span class="ActionScriptDefault_Text">imageUrl</span>;
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">thumbImage</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptOperator">@</span><span class="ActionScriptDefault_Text">thumbImageUrl</span>;
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">rating</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptOperator">@</span><span class="ActionScriptDefault_Text">rating</span>;
                <span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">description</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">flower</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">description</span>;
        
                <span class="ActionScriptDefault_Text">result</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">addItem</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">flowerInstance</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptBracket/Brace">}</span>
            
            <span class="ActionScriptDefault_Text">flowers</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">result</span>;
        <span class="ActionScriptBracket/Brace">}</span>
            
        
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">_flowersXML</span> : <span class="ActionScriptDefault_Text">XML</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">XML</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">_urlRequest</span> : <span class="ActionScriptDefault_Text">URLRequest</span> <span class="ActionScriptOperator">=</span> 
            <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">URLRequest</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">ApplicationManager</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">instance</span><span class="ActionScriptOperator">.</span><span class="ActionScriptDefault_Text">url</span> <span class="ActionScriptOperator">+</span> <span class="ActionScriptString">"data/flowers.xml"</span><span class="ActionScriptBracket/Brace">)</span>; 
        <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">_urlLoader</span> : <span class="ActionScriptDefault_Text">URLLoader</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">URLLoader</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptBracket/Brace">)</span>;
    <span class="ActionScriptBracket/Brace">}</span>
<span class="ActionScriptBracket/Brace">}</span></pre></body>
</html>
